import {Component, OnInit} from '@angular/core';
import {DataService} from "../data_service";
import {Router} from "@angular/router";

@Component({
  selector: 'app-addbook',
  templateUrl: './addbook.component.html',
  styleUrls: ['./addbook.component.css']
})
export class AddbookComponent implements OnInit {
  title="Add Book"
  book: any = {}
  categorys: any = []


  constructor(public service: DataService,public router:Router) {
  }

  ngOnInit(): void {
    this.service.getCategorys().subscribe((resp:any)=>{
      this.categorys=resp
    })
  }

  add() {
    console.log(this.book)
    this.service.postData(this.book).subscribe(_=>{
      this.router.navigate(['/admin'])
    })

  }

}
